package ug.co.icom.kyazze.healthticket;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainAdapter extends ArrayAdapter<String> {

	private Context context;
	
	public MainAdapter(Context context, int resource, int textViewResourceId,
			String[] objects) {
		
		super(context, resource, textViewResourceId, objects);
		this.context = context;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View row = inflater.inflate(R.layout.list_item, parent, false);
		String[] items = context.getResources().getStringArray(R.array.mainitemnames_array);
		
		ImageView im = (ImageView) row.findViewById(R.id.imageView1);
		TextView title = (TextView) row.findViewById(R.id.textView1);
		
		title.setText(items[position]);
		
		if(items[position].equals("Allergies"))
		{
			im.setImageResource(R.drawable.rsz_allergy_);
		}
		else if(items[position].equals("Medication"))
		{
			im.setImageResource(R.drawable.rsz_meds);
		}
		else if(items[position].equals("Immunization Records"))
		{
			im.setImageResource(R.drawable.rsz_immune);
		}
		else if(items[position].equals("Lab Data"))
		{
			im.setImageResource(R.drawable.rsz_lab);
		}
		else if(items[position].equals("Conditions"))
		{
			im.setImageResource(R.drawable.rsz_conditions);
		}
		else if(items[position].equals("Imaging"))
		{
			im.setImageResource(R.drawable.rsz_imaging);
		}
		else if(items[position].equals("Insurance"))
		{
			im.setImageResource(R.drawable.rsz_insurance);
		}
		else if(items[position].equals("Surgeries"))
		{
			im.setImageResource(R.drawable.rsz_surgeon);
		}
		
		
		return row;
	}

}
